var prefix="/wxconfig/";
$(function () {
	valid();
});
$.validator.setDefaults({
    submitHandler: function() {
    	save();
    }
});
function save(){
    var config={
			url : prefix+"/save",
			data:getFormJson("signupForm"),
	}
	EasyAjax.post_json(config,function(r){
		layer.msg(r.msg);
		if (r.code == 0){
			parent.reLoad();
			var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
			parent.layer.close(index);
		} 
	});
	
}
function valid(){
    var icon = "<i class='fa fa-times-circle'></i>";
    $("#signupForm").validate({
    	rules : {
			appid : {
				required : true
			},
			token : {
				required : true
			},
			appSecret : {
				required : true
			}
			,domain : {
				required : true
			}
			,mchId : {
				required : true
			}
			,paternerKey : {
				required : true
			}
			,certPath : {
				required : true
			}
	
		},
		messages : {
			appid : {
				required : icon + "请输入appid"
			},
			token : {
				required : icon + "请输入token"
			},
			appSecret : {
				required : icon + "请输入秘钥"
			},
			domain : {
				required : icon + "请输入域名"
			},
			mchId : {
				required : icon + "请输入商户id"
			},
			paternerKey : {
				required : icon + "请输入支付秘钥"
			},
			certPath : {
				required : icon + "请输证书绝对路径"
			},
		}
    });
}

